#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;


// Loads The .RAW File And Stores It In pHeightMap
void LoadRawFile(const char* strName, int nSize, unsigned char *pHeightMap)
{
	FILE *pFile = NULL;
	
	// Open The File In Read / Binary Mode.
	pFile = fopen( strName, "rb" );
	
	// Check To See If We Found The File And Could Open It
	if ( pFile == NULL )	
	{
		// Display Error Message And Stop The Function
		cerr << "FAILED TO FIND HEIGHT MAP\n";
		return;
	}
	// Here We Load The .RAW File Into Our pHeightMap Data Array
	// We Are Only Reading In '1', And The Size Is (Width * Height)
	fread( pHeightMap, 1, nSize, pFile );
	
	// After We Read The Data, It's A Good Idea To Check If Everything Read Fine
	int result = ferror( pFile );
	
	// Check If We Received An Error
	if (result)
	{
		cerr << "FAILED TO GET DATA\n";
	}
	
	// Close The File
	fclose(pFile);
}
